//
//  ParkEntity.m
//  SXH
//
//  Created by 房 国生 on 15/7/7.
//  Copyright (c) 2015年 lyss. All rights reserved.
//

#import "ParkEntity.h"

@implementation ParkEntity

- (instancetype)initWithAttributes:(NSDictionary *)attributes
{
    self = [super init];
    if (!self) {
        return nil;
    }
    
    self.ID= [attributes valueForKeyPath:@"id"];
    self.title = [attributes valueForKeyPath:@"title"];
    self.is_business = [attributes valueForKeyPath:@"is_business"];
    self.use_baidumap = [attributes valueForKeyPath:@"use_baidumap"];
    self.content = [attributes valueForKeyPath:@"content"];
    if ([attributes valueForKeyPath:@"star"] == nil || [attributes valueForKeyPath:@"star"] == [NSNull null]) {
        self.star = @"0";
    } else {
        self.star = [attributes valueForKeyPath:@"star"];
    }
    
    self.time1 = [attributes valueForKeyPath:@"time1"];
    self.time2 = [attributes valueForKeyPath:@"time2"];
    self.price1 = [attributes valueForKeyPath:@"price1"];
    self.price2 = [attributes valueForKeyPath:@"price2"];
    self.phone = [attributes valueForKeyPath:@"phone"];
    self.address = [attributes valueForKeyPath:@"address"];
    self.memoinfo = [attributes valueForKeyPath:@"memo_info"];
    self.map_image = [NSString stringWithFormat:@"%@/%@", IMAGE_URL, [attributes valueForKeyPath:@"map_image"]];
    self.longitude = [attributes valueForKeyPath:@"longitude"];
    self.latitude = [attributes valueForKeyPath:@"latitude"];
    self.album = [NSString stringWithFormat:@"%@/%@", IMAGE_URL, [attributes valueForKeyPath:@"album"]];
    
    NSNumber *number_comment_count = [attributes valueForKeyPath:@"comment_count"];
    self.commentCount = [NSString stringWithFormat:@"%d", [number_comment_count intValue]];
    self.album_thumb = [NSString stringWithFormat:@"%@/%@", IMAGE_URL, [attributes valueForKeyPath:@"album_thumb"]];
    
    self.highWD = [attributes valueForKeyPath:@"high_wd"];
    self.lowWD = [attributes valueForKeyPath:@"low_wd"];
    self.weatherIcon = [NSString stringWithFormat:@"%@/%@", IMAGE_URL, [attributes valueForKeyPath:@"weather_icon"]];
    
    self.map_width = [attributes valueForKeyPath:@"map_width"];
    self.map_height = [attributes valueForKeyPath:@"map_height"];
    self.ticket_url = [attributes valueForKeyPath:@"ticket_url"];
    self.questionnaire_url = [attributes valueForKeyPath:@"questionnaire_url"];
    
    
    self.radius = [attributes valueForKeyPath:@"radius"];
    
    self.activity_rows = [attributes valueForKeyPath:@"activity_rows"];
    self.park_rows = [attributes valueForKeyPath:@"park_rows"];
    self.notice_rows = [attributes valueForKeyPath:@"notice_rows"];
    self.attraction_class = [attributes valueForKeyPath:@"attraction_class"];
    self.business_class = [attributes valueForKeyPath:@"business_class"];
    self.park_class = [attributes valueForKeyPath:@"park_class"];
    self.city_id = [attributes valueForKeyPath:@"city_id"];
    self.level = [attributes valueForKeyPath:@"level"];
    self.source_version = [attributes valueForKey:@"source_version"];
    self.animal_knowledge  = [attributes valueForKey:@"animal_knowledge"];
    
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:self.ID forKey:@"ID"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.is_business forKey:@"is_business"];
    [aCoder encodeObject:self.use_baidumap forKey:@"use_baidumap"];
    [aCoder encodeObject:self.content forKey:@"content"];
    [aCoder encodeObject:self.star forKey:@"star"];
    [aCoder encodeObject:self.time1 forKey:@"time1"];
    [aCoder encodeObject:self.time2 forKey:@"time2"];
    [aCoder encodeObject:self.price1 forKey:@"price1"];
    [aCoder encodeObject:self.price2 forKey:@"price2"];
    [aCoder encodeObject:self.phone forKey:@"phone"];
    [aCoder encodeObject:self.address forKey:@"address"];
    [aCoder encodeObject:self.memoinfo forKey:@"memoinfo"];
    [aCoder encodeObject:self.map_image forKey:@"map_image"];
    [aCoder encodeObject:self.longitude forKey:@"longitude"];
    [aCoder encodeObject:self.latitude forKey:@"latitude"];
    [aCoder encodeObject:self.album forKey:@"album"];
    [aCoder encodeObject:self.commentCount forKey:@"commentCount"];
    [aCoder encodeObject:self.album_thumb forKey:@"album_thumb"];
    [aCoder encodeObject:self.highWD forKey:@"highWD"];
    [aCoder encodeObject:self.lowWD forKey:@"lowWD"];
    [aCoder encodeObject:self.weatherIcon forKey:@"weatherIcon"];
    [aCoder encodeObject:self.map_width forKey:@"map_width"];
    [aCoder encodeObject:self.map_height forKey:@"map_height"];
    [aCoder encodeObject:self.package_size forKey:@"package_size"];
    [aCoder encodeObject:self.local_path forKey:@"local_path"];
    [aCoder encodeObject:self.ticket_url forKey:@"ticket_url"];
    [aCoder encodeObject:self.ticket_url forKey:@"questionnaire_url"];
    
    [aCoder encodeObject:self.radius forKey:@"radius"];
    [aCoder encodeObject:self.activity_rows forKey:@"activity_rows"];
    [aCoder encodeObject:self.park_rows forKey:@"park_rows"];
    [aCoder encodeObject:self.notice_rows forKey:@"notice_rows"];
    [aCoder encodeObject:self.attraction_class forKey:@"attraction_class"];
    [aCoder encodeObject:self.business_class forKey:@"business_class"];
    [aCoder encodeObject:self.isSpot forKey:@"isSpot"];
    [aCoder encodeObject:self.park_class forKey:@"park_class"];
    [aCoder encodeObject:self.level forKey:@"level"];
    [aCoder encodeObject:self.source_version forKey:@"source_version"];
    [aCoder encodeObject:self.animal_knowledge forKey:@"animal_knowledge"];
    
}

- (id)initWithCoder:(NSCoder *)decoder{
    self = [super init];
    if(self != nil){
        if(self = [super init]) {
            self.ID = [decoder decodeObjectForKey:@"ID"];
            self.title = [decoder decodeObjectForKey:@"title"];
            self.is_business = [decoder decodeObjectForKey:@"is_business"];
            self.use_baidumap = [decoder decodeObjectForKey:@"use_baidumap"];
            self.content = [decoder decodeObjectForKey:@"content"];
            self.star = [decoder decodeObjectForKey:@"star"];
            self.time1 = [decoder decodeObjectForKey:@"time1"];
            self.time2 = [decoder decodeObjectForKey:@"time2"];
            self.price1 = [decoder decodeObjectForKey:@"price1"];
            self.price2 = [decoder decodeObjectForKey:@"price2"];
            self.phone = [decoder decodeObjectForKey:@"phone"];
            self.address = [decoder decodeObjectForKey:@"address"];
            self.memoinfo = [decoder decodeObjectForKey:@"memoinfo"];
            self.map_image = [decoder decodeObjectForKey:@"map_image"];
            self.longitude = [decoder decodeObjectForKey:@"longitude"];
            self.latitude = [decoder decodeObjectForKey:@"latitude"];
            self.album = [decoder decodeObjectForKey:@"album"];
            self.commentCount = [decoder decodeObjectForKey:@"comment_count"];
            self.album_thumb = [decoder decodeObjectForKey:@"album_thumb"];
            self.highWD = [decoder decodeObjectForKey:@"high_wd"];
            self.lowWD = [decoder decodeObjectForKey:@"low_wd"];
            self.weatherIcon = [decoder decodeObjectForKey:@"weather_icon"];
            self.map_width = [decoder decodeObjectForKey:@"map_width"];
            self.map_height = [decoder decodeObjectForKey:@"map_height"];
            self.ticket_url = [decoder decodeObjectForKey:@"ticket_url"];
            self.package_size = [decoder decodeObjectForKey:@"package_size"];
            self.local_path = [decoder decodeObjectForKey:@"local_path"];
            self.questionnaire_url = [decoder decodeObjectForKey:@"questionnaire_url"];
            self.activity_rows = [decoder decodeObjectForKey:@"activity_rows"];
            self.park_rows = [decoder decodeObjectForKey:@"park_rows"];
            self.notice_rows = [decoder decodeObjectForKey:@"notice_rows"];
            self.radius = [decoder decodeObjectForKey:@"radius"];
            self.attraction_class = [decoder decodeObjectForKey:@"attraction_class"];
            self.isSpot = [decoder decodeObjectForKey:@"isSpot"];
            self.park_class = [decoder decodeObjectForKey:@"park_class"];
            self.business_class  = [decoder decodeObjectForKey:@"business_class"];
            self.level  = [decoder decodeObjectForKey:@"level"];
            self.source_version = [decoder decodeObjectForKey:@"source_version"];
            self.animal_knowledge = [decoder decodeObjectForKey:@"animal_knowledge"];
        }
    }
    return self;
}

@end
